<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
$this->load->view('logged_in/admin/header', array('current_page' => 1));

?>
<!-- Main Wrapper -->

<div id="main-wrapper">
	<div class="container">

		<div class="row">
			<?php $this->load->view('logged_in/admin/panel'); ?>
			<div class="8u skel-cell-important">

				<!-- Content -->
				<div class="10u panel panel-default" style="margin: 0 auto; text-align: center; border: none;">
					<table class="table mytable">
						<tbody>
						<tr>
							<th style="width: 10%">#</th>
							<th>Article</th>
							<th colspan="2" style="width: 40%;">Action</th>
						</tr>
						<?php
						$i = 0;
						foreach ($articles as $article) {
							?>
							<tr>
								<input name="id" type="hidden" value="<?php echo $article['id'] ?>">
								<td><b><?php echo $i++; ?></b></td>
								<td>
									<a class="articles"
									   href="<?php echo base_url() . 'blog/article/' . $article['id']; ?>">
										<h3 style="margin: 0 .5em; text-align: left;"><?php echo $article['title'] ?></h3>
									</a>
								</td>
								<td>
									<a class="btn btn-warning btn-sm" style="text-decoration: none"
									   href="<?php echo base_url() . 'admin/editArticle/' . $article['id']; ?>">Edit
								</td>
								</td>
								<td>
									<a class="btn btn-danger btn-sm" style="text-decoration: none;"
									   id="<?php echo 'delArticle_' . $article['id'] ?>"
									   onclick="confirmDel(event)"
									   href="#">Delete</a>
								</td>
							</tr>


						<?php } ?>
						</tbody>
					</table>
				</div>
				<div class="8u" style="margin: 0 auto; margin-top: 2em; text-align: center">
					<div class=" btn-group btn-group btn-group-lg">
						<?php echo $pagination ?>
					</div>

				</div>
			</div>
		</div>
	</div>
</div>
<script>
	function confirmDel(event) {
		id = event.target.id.split("_")[1];
		var ask = confirm("Are you sure?");
		if (ask == true) {
			window.location.assign("<?php echo base_url().'admin/deleteArticle/';?>" + id);
		}
		e.preventDefault();
		return false;
	}
</script>
<?php
$this->load->view('logged_in/components/footer');
?>
